package com.wpf.servlet;

import com.wpf.bean.Userbean;
import com.wpf.dao.UserDAO;
import java.io.IOException;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;
public class QueryByID extends HttpServlet {
	private static final long serialVersionUID = 1L;
    public QueryByID() {}
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();
		UserDAO userdao = new UserDAO();
		Userbean userbean = new Userbean();
		String ID = request.getParameter("id");
		if(ID==""||ID==null) {
			session.setAttribute("operationtip","<font size='2' color='red'>请求学号错误！</font>");
		}else {
			userbean = userdao.find(Integer.parseInt(ID));
			session.setAttribute("edituser",userbean);
			request.getRequestDispatcher("/wpf_updata.jsp").forward(request, response);
		}
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
